package com.yupi.springbootinit.service;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yupi.springbootinit.enums.SearchKeyWord;
import com.yupi.springbootinit.model.vo.PictureVo;
import com.yupi.springbootinit.model.vo.PostVO;
import com.yupi.springbootinit.model.vo.SearchVo;
import org.springframework.stereotype.Service;

import java.io.Serializable;

@Service
public interface UserSearchService {

    <T extends Serializable> Page<T> search(String searchText, SearchKeyWord keyWord, int paeSize, int pageNo);


    default Page<PostVO> postSearch(String searchText, int paeSize, int pageNo) {
        return search(searchText, SearchKeyWord.POST, paeSize, pageNo);
    }


    default Page<PictureVo> pictureSearch(String searchText, int paeSize, int pageNo) {
        return search(searchText, SearchKeyWord.PICTURE, paeSize, pageNo);
    }

    default SearchVo allSearch(String searchText, int paeSize, int pageNo) {
        SearchVo searchVo = new SearchVo();
        searchVo.setPicture(search(searchText, SearchKeyWord.PICTURE, paeSize, pageNo));
        searchVo.setPost(search(searchText, SearchKeyWord.POST, paeSize, pageNo));
        return searchVo;
    }

}
